package webshop.beans;

import java.util.ArrayList;
import java.util.List;

import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;

import database.entity.UserGroup;
import database.entitymanager.UserGroupManager;

public class UserGroupBean extends UserGroup {

	private int scrollerPage = 1;
	private UserGroup selectedUserGroup = null;

	private static final long serialVersionUID = -8577820237581098333L;

	public UserGroupBean() {
		super();
	}
	
	
	List<UserGroup> retVal = null;

	public List<UserGroup> getAllUserGroups() {
		if (retVal == null) {
			retVal = new ArrayList<UserGroup>();
			retVal.add(new UserGroup(0, "SuperAdmin", 200));
			retVal.add(new UserGroup(1, "Admin", 150));
			retVal.add(new UserGroup(2, "Moderator", 100));
			retVal.add(new UserGroup(3, "SuperUser", 50));
			retVal.add(new UserGroup(4, "User", 10));
		}

		return retVal;
	}

	public UserGroupBean(Integer ugid) {
		super(ugid);
	}

	public UserGroupBean(Integer ugid, String ugname, int ugauthoritylevel) {
		super(ugid, ugname, ugauthoritylevel);
	}

	public int getScrollerPage() {
		return scrollerPage;
	}

	public void setScrollerPage(int scrollerPage) {
		this.scrollerPage = scrollerPage;
	}

	public void edit() {
		FacesContext context = FacesContext.getCurrentInstance();
		String paramVaule = (String) context.getExternalContext()
				.getRequestParameterMap().get("UserGroupID");
		
	}

	public void save(ActionEvent event) {
		//retVal.add(selectedUserGroup);
	}

	public void remove(ActionEvent event) {
		retVal.remove(selectedUserGroup);
	}

	public void setSelectedUserGroup(UserGroup selectedUserGroup) {
		this.selectedUserGroup = selectedUserGroup;
	}

	public UserGroup getSelectedUserGroup() {
		return selectedUserGroup;
	}
}
